﻿using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace CloudTaobao.Util
{
    public class DecodeTOPParam
    {
        string decoded;
        IDictionary<string, string> props = new Dictionary<string,string>();

        public DecodeTOPParam(string top_param)
        {
            byte[] bytes = Convert.FromBase64String(top_param);
            decoded = Encoding.GetEncoding("utf-8").GetString(bytes,0,bytes.Length);
            string[] pairs = decoded.Split(new char[]{'&'});
            foreach (string pair in pairs)
            {
                string[] param = pair.Split(new char[] { '=' });
                props.Add(param[0], param[1]);
            }
        }

        public string getProp(string propName)
        {
            return props[propName];
        }
    }
}
